package com.atguigu.lease.web.app.custom.config;

import com.atguigu.lease.web.app.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Description:
 *
 * @author Yanxinhao on 2024/11/21
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private AuthenticationInterceptor authenticationInterceptor;
     @Value("${app.auth.path-patterns.include}")
    private String[] includePathPatterns;
    @Value("${app.auth.path-patterns.exclude}")
    private String[] excludePathPatterns;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        registry.addInterceptor(authenticationInterceptor).addPathPatterns(includePathPatterns)
                .excludePathPatterns(excludePathPatterns);
    }
}